/*! \file mem_profile.h
 *	\brief <write description for mem_profile.h>
 *
 *	created:	2009/11/20
 *	created:	20:11:2009   18:26
 *	filename: 	o:\main\libs\mem\mem_profile.h
 *	file path:	o:\main\libs\mem
 *	file base:	mem_profile
 *	file ext:	h
 *	author:		Vitalii Trubchaninov
 *				venngraydog@gmail.com
 */

#ifndef _MEM_MEM_PROFILE_H_
#define _MEM_MEM_PROFILE_H_

#pragma once

#if TT_MEM_ENABLED && TT_MEM_PROFILING

#include "profile_section.h"

namespace tt{
namespace mem{
	MEM_API void serialize(const char* file_name, bool append);

	MEM_API void* root_section(const char* root_section_name);
	MEM_API void register_new(void* section, unsigned int size);
	MEM_API void register_delete(void* section, unsigned int size);
}
} //namespace tt

#define MEM_SECTION(name) tt::mem::ProfileSection<mem::starters::Normal> mem_block(name)
#define MEM_SECTION_N(name, num) tt::mem::ProfileSection<mem::starters::Normal> mem_block##num(name)
#define MEM_SECTION_TO_ROOT(name) tt::mem::ProfileSection<mem::starters::ToRoot> mem_block(name)
//#define PROFILE_BLOCK_TO_ROOT(name) profile::ProfileBlock block(name, true)
//#define PROFILE_VALUE(name, value) profile::profile_value(name, value)
//#define PROFILE_RESET profile::reset()
//#define PROFILE_SAVE_AND_RESET(file_name) profile::save_and_reset(file_name)
#define MEM_SERIALIZE(file_name) tt::mem::serialize(file_name, true)

#define MEM_ROOT_SECTION(root_section_name) tt::mem::root_section(root_section_name)
#define MEM_REGISTER_NEW(section, size) tt::mem::register_new(section, size)
#define MEM_REGISTER_DELETE(section, size) tt::mem::register_delete(section, size)

#else //TT_MEM_ENABLED && TT_MEM_PROFILING

#define MEM_SECTION(name) ((void)0)
#define MEM_SECTION_N(name, num) ((void)0)
#define MEM_SECTION_TO_ROOT(name) ((void)0)
// #define PROFILE_VALUE(name, value) ((void)0)
// #define PROFILE_RESET ((void)0)
// #define PROFILE_SAVE_AND_RESET(file_name) ((void)0)
#define MEM_SERIALIZE(file_name) ((void)0)

#define MEM_ROOT_SECTION(root_section_name) (0)
#define MEM_REGISTER_NEW(section, size) ((void)0)
#define MEM_REGISTER_DELETE(section, size) ((void)0)

#endif //TT_MEM_ENABLED && TT_MEM_PROFILING

#endif //_MEM_MEM_PROFILE_H_
